import ajax from "./ajax";

const params = (obj)=> {
    let result = '';
    let item;
    for (item in obj) {
        result += `&${item}=${obj[item]}`;
    }
    if (result) {
      result = '?' + result.slice(1);
    }
    return result;
  }


export  const girls = () => {
   return ajax({
       url:'https://gank.io/api/v2/data/category/Girl/type/Girl/page/1/count/50',
       method:'GET'
   })
}

//注册
export  const resigster = (data) => {
    return ajax({
        url:'/api/v1/users',
        method:'POST',
        data:data
    })
 }

 //登录
export  const authorizations = (data) => {
    return ajax({
        url:'/api/v1/authorizations',
        method:'POST',
        data:data
    })
 }

 //发送短信
 export  const sendcode = (data) => {
    return ajax({
        url:'/api/v1/verificationCodes',
        method:'POST',
        data:data
    })
 }

//修改密码
export  const passchange = (data) => {
    return ajax({
        url:'/api/v1/password',
        method:'POST',
        data:data
    })
 }

//忘记密码
export  const forget = (data) => {
    return ajax({
        url:'/api/v1/forget',
        method:'POST',
        data:data
    })
 }

 //个人信息
 export  const me = () => {
    return ajax({
        url:'/api/v1/me',
        method:'GET',
    })
 }

 //首页轮播图
export  const banner = (data) => {
    return ajax({
        url:'/api/v1/banner',
        method:'GET',
        data:data
    })
 }

  //滚动公告列表
export  const bulletin = (data) => {
    return ajax({
        url:'/api/v1/bulletin?type=carousel',
        method:'GET',
        data:data
    })
 }

  //滚动公告列表
  export  const bulletinID = (data) => {
    return ajax({
        url:`/api/v1/bulletin/${data.id}`,
        method:'GET',
        data:data
    })
 }

  //弹出公告列表
  export  const bulletin_eject = (data) => {
    return ajax({
        url:'/api/v1/bulletin?type=eject',
        method:'GET',
        data:data
    })
 }

   //收益统计
export  const profit_statistics = (data) => {
    return ajax({
        url:'/api/v1/profit_statistics',
        method:'GET',
        data:data
    })
 }

   //文章接口
export  const abuouts = () => {
    return ajax({
        url:'/api/v1/articles?key=AboutUs&page=1&limit=10',
        method:'GET',
    })
 }

   //文章列表
export  const articles = (data) => {
    return ajax({
        url:`/api/v1/articles${params(data)}`,
        method:'GET',
        data:data
    })
 }

   //文章列表
export  const articlesID = (data) => {
    return ajax({
        url:`/api/v1/articles/${data.id}`,
        method:'GET',
    })
 }

    //客服
export  const customers = () => {
    return ajax({
        url:'/api/v1/problems',
        method:'GET',
    })
 }

   //咨询列表
export  const Consultation = (data) => {
    return ajax({
        url:"/api/v1/articles/home",
        method:'GET',
    })
 } 

   //抢单列表
export  const grabOrders = () => {
    return ajax({
        url:"/api/v1/grabOrders",
        method:'GET',
    })
 } 

   //抢单
export  const grabOrder = (data) => {
    return ajax({
        url:"/api/v1/grabOrders",
        method:'POST',
        data:data
    })
 } 

   //购买列表
export  const payments = (data) => {
    return ajax({
        url: `/api/v1/payments${params(data)}`,
        method:'GET',
    })
 } 

   //售卖
export  const sell = (data) => {
    return ajax({
        url: `/api/v1/sale/status`,
        method:'POST',
        data:data
    })
 } 

   //资金明细
export  const accounts = (data) => {
    return ajax({
        url: `/api/v1/accounts${params(data)}`,
        method:'GET',
    })
 } 

    //兑换列表
export  const sales = (data) => {
    return ajax({
        url: `/api/v1/sale/payments${params(data)}`,
        method:'GET',
    })
 } 


   //修改个人资料
export  const avatar = (data) => {
    return ajax({
        url:"/api/v1/user",
        method:'PATCH',
        data:data
    })
 } 

   //激活账号
export  const activation = (data) => {
    return ajax({
        url:"/api/v1/teams/activation",
        method:'POST',
        data:data
    })
 } 

   //银行卡列表
export  const cards = (data) => {
    return ajax({
        url:"/api/v1/cards",
        method:'GET'
    })
 } 

   //添加银行卡
export  const addcards = (data) => {
    return ajax({
        url:"/api/v1/cards",
        method:'POST',
        data:data
    })
 }

   //编辑银行卡
export  const editcards = (data) => {
    return ajax({
        url:`/api/v1/cards/${data.id}`,
        method:'PATCH',
        data:data
    })
 }

   //银行卡详情
export  const infocards = (data) => {
    return ajax({
        url:`/api/v1/cards/${data.id}`,
        method:'GET',
    })
 }

   //设置默认银行卡
export  const defaultcards = (data) => {
    return ajax({
        url:`/api/v1/cards/${data.id}/default`,
        method:'PATCH',
    })
 }

   //删除银行卡
export  const deltecards = (data) => {
    return ajax({
        url:`/api/v1/cards/${data.id}`,
        method:'DELETE',
    })
 }

    //意见反馈
export  const complaints = (data) => {
    return ajax({
        url:"/api/v1/complaints",
        method:'POST',
        data:data
    })
 } 

     //下载接口
export  const versions = (data) => {
    return ajax({
        url:`/api/v1/versions?type=${data.type}`,
        method:'GET',
    })
 } 